package lab02.test13;

public class Gymnastics extends ComputerAverage {

    //求平均值
    @Override
    double average(double[] scores) {
        for (int i = 0; i < scores.length - 1; i++) {
            for (int j = i; j < scores.length - 1; j++) {
                if (scores[i] > scores[i + 1]) {
                    double temp = scores[i];
                    scores[i] = scores[i + 1];
                    scores[i + 1] = temp;
                }
            }
        }
        double sum = 0;
        for (int i = 1; i < scores.length - 1; i++) {
            sum += scores[i];
        }
        double average = sum / (scores.length - 2);
        return average;
    }
}
